﻿using System.Collections.Generic;
using UnityEngine;

namespace Script
{
    public abstract class NodeShape
    {
        public List<NodeSquare> nodeList = new List<NodeSquare>();

        protected NodeShape(GameObject res)
        {
            
        }

        public void MoveDown()
        {
            foreach (var nodeSquare in nodeList)
            {
                if (nodeSquare.CheckSquareCanMove(0,-1) == false)
                {
                    return;
                }
            }
            foreach (var nodeSquare in nodeList)
            {
                nodeSquare.MoveDown();
            }
        }

        public void MoveLeft()
        {
            foreach (var nodeSquare in nodeList)
            {
                if (nodeSquare.CheckSquareCanMove(-1,0) == false)
                {
                    return;
                }
            }
            foreach (var nodeSquare in nodeList)
            {
                nodeSquare.MoveLeft();
            }
        }

        public void MoveRight()
        {
            foreach (var nodeSquare in nodeList)
            {
                if (nodeSquare.CheckSquareCanMove(1,0) == false)
                {
                    return;
                }
            }
            foreach (var nodeSquare in nodeList)
            {
                nodeSquare.MoveRight();
            }
        }

        public abstract void MoveRotation();

    }
}